import { http } from '@/utils/http'
export interface UploadData {
  file: any
  name: string
  type: 'image' | 'video' | 'audio' | 'file'
}

export interface UploadRes {
  name: string
  type: number
  url: string
}

export const uploadFile = (data: UploadData) => {
  return http.request<UploadRes>(
    'post',
    '/api/files',
    { data },
    {
      headers: {
        'Content-Type': 'multipart/form-data'
      }
    }
  )
}

export const findFileByHash = (hash: string) => {
  return http.request<UploadRes>('get', `/api/files?hash=${hash}`)
}
